package com.smh.a07CommonsIODemo1;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;

public class CommonsIoDemo1 {
    public static void main(String[] args) throws IOException {
        //Apache组织的产物
        //工具包
        //Fileutils类
        //static void copyfile(File srcFile, File destFile)复制文件
        //static void copyDirectory(File srcDir, File destDir)复制文件夹
        //static void copyDirectoryToDirectory(File srcDir, file destDir)复制文件夹
        //static void deleteDirectory(File directory)删除文件夹
        //static void cleanDirectory(File directory)清空文件夹
        //static string readFileToString(File file, charset encoding)读取文件中的数据变成成字符串
        //static void write(File file, CharSequence data, string encoding)写出数据
        //Ioutils类
        //public static int copy(Inputstream input, Outputstream output)public static int copyLarge(Reader input, Writer output)复制文件
        //public static string readLines(Reader input)复制大文件
        //public static void write(string data, Outputstream output)读取数据写出数据

        /*File src= new File("day27-code\\file\\demo5\\a.txt");
        File dest= new File("day27-code\\file\\demo5\\b.txt");
        FileUtils.copyFile(src,dest);
        */

   /*     File src1 = new File("day27-code\\file\\demo5\\aaa");
        File dest1 = new File("day27-code\\file\\demo5\\bbb");

        FileUtils.copyDirectory(src1,dest1);//只拷贝文件夹里面的内容
        FileUtils.copyDirectoryToDirectory(src1,dest1);//将文件夹本身直接拷贝过去
*/
        /*File src = new File("day27-code\\file\\demo5\\bbb");
//        FileUtils.deleteDirectory(src);//删除文件夹

        FileUtils.cleanDirectory(src);//清空文件夹*/

        File src = new File("day27-code\\file\\csb.txt");
        String s = FileUtils.readFileToString(src);
        System.out.println(s);

        File dest = new File("day27-code\\file\\demo5\\c.txt");
        FileUtils.write(dest, "sadsadasd", Charset.forName("UTF-8"));


    }
}
